class CreatePurchaseOrderHxes < ActiveRecord::Migration
  def self.up
    create_table :purchase_order_hxes do |t|
      t.integer :company_id            ,:null => false         #所属公司的ID
      t.integer :department_id         ,:null => false         #申请采购的部门ID
      t.integer :employee_id           ,:null => false         #申请采购的部门的员工ID
      t.integer :purchase_order_id     ,:null => false         #采购订单ID
      t.integer :vendor_id             ,:null => false         #产品供应商ID
      t.integer :seq_number    , :default => 0  #流水号
      t.string  :order_number                   #单号
      t.date    :action_date                    #要求到货日期(其实是预计或期望到期日期)
      t.string  :description                    #写一些备注之类的信息
      t.decimal :amount  , :precision => 10, :scale => 2  ,:default => 0   #总价格
      t.decimal :tax_amount  , :precision => 10, :scale => 2  ,:default => 0   #含税总价格
      t.decimal :value_added_tax  ,:null => false , :precision => 8, :scale => 2  ,:default => 0   #增值税
      t.integer :is_locked     ,:limit => 1 ,:default => 0 #锁定 1为True 0为False
      t.integer :lock_version  , :default => 0  #乐观锁
      t.timestamps
    end
  end

  def self.down
    drop_table :purchase_order_hxes
  end
end
